package fr.xebia.monitoring;

import java.util.Random;

import org.apache.log4j.Level;
import org.apache.log4j.Logger;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Logger.getLogger("org.springframework").setLevel(Level.INFO);
		MonitorFactory.init();

		Thread testThread = new Thread(new Runnable() {
			public void run() {
				Random randomizer = new Random();
				Logger.getLogger(getClass()).debug("Simulating work ...");
				while (true) {
					Monitor monitor = MonitorFactory.start("Test", "testThread.run()");
					int pause = randomizer.nextInt(1000);
					try {
						Thread.sleep((long) pause);
					} catch (InterruptedException e) {
						break ;
					} finally {
						monitor.stop();
					}
				}
			}
		});
		testThread.start();
	}

}
